<?php 
session_start(); 
include 'connect.php';	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<link rel="stylesheet" type="text/css" href="styles.css"/>
</head>
<body>
<div class="logo"></div> 
<div id="container">
<div id="MainContent">
<div id="user">
<?php
			
			if (isset($_SESSION['MemberID'])){
					echo "Hi, ".$_SESSION['Username'].".<br />";
				}
				?>

<?php if (isset($_SESSION['MemberID'])){ echo "<a href='logout.php'>Logout</a>";}?>
</div>
<div class="clear"></div>

<div class="linksContainer">
<?php 

//print_r($_SESSION['MemberID']);
if(isset($_SESSION['MemberID'])){
	echo "<a href='welcome.php'  class='links'>Home Page</a>";
	echo "<a href='memberProfile.php' class='links'>My Profile</a>";
	echo "<a href='memberProjects.php' class='links'>My Projects</a>";
	echo "<a href='projMan.php' class='links'>View Current Projects</a>";
	echo "<a href='createProject.php' class='links'>Create a Project</a>";

			}
			else echo "Please <a href='index.php'>login</a> to access this page.";
			

?>
</div><!--linksContainer-->
				<?php
				//print_r($_SESSION);
				if (isset($_SESSION['MemberID'])){
				$query = "SELECT DISTINCT p.ProjectName, p.Description FROM members m, project p WHERE ".$_SESSION['MemberID']."=p.CreatorID";
				$result = mysql_query($query);
				if (!$result) {
				    $message  = 'Invalid query: ' . mysql_error() . "\n";
				    $message .= 'Whole query: ' . $query;
				    die($message);
				}
				
				
				
				// While a row of data exists, put that row in $row as an associative array
				// Note: If you're expecting just one row, no need to use a loop
				
				
				//if ($row = mysql_fetch_assoc($result)) {
				while($row = mysql_fetch_array($result)) {
					
					$projectTitle = $row["ProjectName"];
					$projectDescription = $row["Description"];
					
					echo '<table>';
				    echo '<tr><td>Project Name:</td><td>'.$projectTitle. '</td></tr></br>';
				    echo '<tr><td>Description:</td><td>'.$projectDescription. "</td></tr>";
				    echo "<tr><td><a href='MemberProjectsUpdate.php'>Edit</a></td>";
				    echo '</table>';
				    echo "<hr />";
				}
				//else echo "<p>Currently you do not have any active projects nor are you a member of any projects</p>";
				($result);
				mysql_close($connection);
				}
		else echo "Please <a href='index.php'>login</a> to access this page.";		
				?>
			</div>
			</div>
</body>
</html>